//
//  PopRootView.h
//  popRootView
//
//  Created by DWE _WODE on 16/9/24.
//  Copyright © 2016年 popRootView. All rights reserved.
//

#import <UIKit/UIKit.h>

/**
 *  弹框类型
 */
typedef NS_ENUM(NSInteger, CTLActionStyle)
{
    CTLActionStyleDefault = 0,  //默认
    CTLActionStyleCancel,       //取消
    CTLActionStyleDestructive
}NS_ENUM_AVAILABLE_IOS(8_0);

/**
 *  警告类型
 */
typedef NS_ENUM(NSInteger, CTLAlertStyle)
{
    CTLAlertStyleBarStyle = 0,
    CTLAlertStyleLineStyle,
}NS_ENUM_AVAILABLE_IOS(8_0);

@interface CTLAction : NSObject

@property (nonnull, nonatomic, copy) void (^aHandler) (CTLAction *_Nullable action);
/**
 *  设置头部标题 (包含视图类型)
 */
+ (nonnull instancetype)actionWithTitle:(nullable NSString *)title style:(CTLActionStyle)style handler:(void (^ __nullable)(CTLAction *_Nullable action))handler;

/**
 *  设置头部标题
 */
+ (nonnull instancetype)actionWithTitle:(nullable NSString *)title handler:(void (^ __nullable)(CTLAction *_Nullable action))handler;

@property (nullable, nonatomic, readonly) NSString *titleStr;
@property (nonatomic, readonly) CTLActionStyle style;
@property (nonatomic, getter=isEnabled) BOOL enabled;
@end

/**
 *  自定协议
 */
@protocol CTLPopupRootComponent <NSObject>

@optional
/**
 * 显示
 */
- (void)show;

/**
 *  消失
 */
- (void)dismiss;

/**
 *  显示Block
 */
- (void)showWithCompletion:(nullable dispatch_block_t)aCompletion;

/**
 *  消失Block
 */
- (void)dismissWithCompletion:(nullable dispatch_block_t)aCompletion;

/**
 *  添加弹框
 */
- (void)addAction:(nonnull CTLAction*)action;


@end

/**
 *  弹框视图
 */
@interface PopRootView : UIView<CTLPopupRootComponent>
@property (nonnull, nonatomic ,strong) UIView *backgroundView;//背景视图
@property (nonnull, nonatomic, strong) UIView *contentView;//内容视图
@property (nonnull, nonatomic, strong) NSMutableArray *actionArray;//视图数组
@end


#pragma mark - alert弹框基类
@interface CTLAlertComponent : PopRootView
@property (nonnull, nonatomic, strong, readonly) UILabel *titleLabel;
@property (nonnull, nonatomic, strong, readonly) UILabel *messageLabel;
@property (nullable ,nonatomic, strong) CAShapeLayer *drawPathLayer;
@end

#pragma mark - sheet表单弹框基类
@interface CTLSheetComponet : PopRootView
@property (nonnull, nonatomic, strong, readonly) UILabel *titleLabel;
@property (nonnull, nonatomic, strong, readonly) UILabel *messageLabel;
@property (nonnull, nonatomic, strong, readonly) UITableView *tableView;
@end

